home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93a.txt / 000114_icon-group-sender _Sat Apr 10 18:23:43 1993.msg < prev    next >
Internet Message Format  |  1993-04-21  |  3KB

  1. Received: by cheltenham.cs.arizona.edu; Sat, 10 Apr 1993 18:26:58 MST
  2. Date: Sat, 10 Apr 93 18:23:43 -0700
  3. From: wgg@cs.ucsd.edu (William Griswold)
  4. Message-Id: <9304110123.AA29740@gremlin>
  5. To: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uwm.edu!linac!uchinews!quads!goer@ucbvax.Berkeley.EDU,
  6.         icon-group@cs.arizona.edu
  7. Subject: Re: Icon rookie problems solved
  8. Status: R
  9. Errors-To: icon-group-errors@cs.arizona.edu
  10.  
  11. >From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uwm.edu!linac!uchinews!quads!goer@ucbvax.Berkeley.EDU  (Richard L. Goerwitz)
  12. >Subject: Re: Icon rookie problems solved
  13. >
  14. >bweiss@cs.arizona.edu (Beth Weiss) writes:
  15. >...
  16. >    procedure genchar(s,c)
  17. >        suspend s[upto(c,s)]
  18. >    end
  19. >
  20. >If it's this easy, why encapsulate it in a separate procedure??
  21. >
  22. >    procedure main()
  23. >        stuff...
  24. >        every write(s[upto(c, s)])
  25. >-- 
  26. >   -Richard L. Goerwitz              goer%midway@uchicago.bitnet
  27. >   goer@midway.uchicago.edu          rutgers!oddjob!ellis!goer
  28.  
  29. There are at least four reasons:
  30.  
  31.     1) genchar is a suggestive, easy-to-remember name compared to the
  32.        alternative;
  33.  
  34.     2) reducing 6 elements (s, upto, [], (), c, s) down to 4 (genchar, (),
  35.        c, s) reduces the chance of making a mistake in the use and
  36.        placement of the elements;
  37.  
  38.     3) `s', which appears twice in the solution, could be a
  39.        complicated, even side-effecting, expression, destroying the
  40.        simplicity (and perhaps the correctness) of your at-first-glance
  41.        simple solution;
  42.  
  43.     4) if you were ever to come up with a better implementation of genchar
  44.        (such as reimplementing it as a built-in function or caching the
  45.        cset-value of c [if it's actually a string, say] to avoid having to
  46.        repeatedly coerce it), you could perform one change to the
  47.        implementation of genchar and all calls of genchar would benefit
  48.        from that change upon recompilation.  Otherwise you could be
  49.        faced with recognizing and changing all instances of s[upto(c,s)]
  50.        for all s and c, general expressions (in all of your programs).
  51.  
  52. The basic principle at work here is ``information hiding'', which assists
  53. the programmer in localizing the effects of antipicated changes to the
  54. design or implementation of a program.  By hiding a design decision in a
  55. module (in this case a single function), it is possible to change that
  56. decision with local, rather than global, changes.  See:
  57.  
  58.   D. L. Parnas, "On the Criteria to be Used in Decomposing Systems into
  59.   Modules", Communications of the ACM, December 1972.
  60.  
  61.  
  62.                         Bill Griswold
  63.                         wgg@cs.ucsd.edu
  64.